<?php

namespace app\api\controller;

use think\facade\Db;
use think\facade\Log;

/**
 * 电费异步通知回调.
 */
class PowerNotify extends \app\BaseController
{
    /**
     * 微客云电费充值回调.
     */
    public function wikeyun()
    {
        $info = Db::name('base_supplier')
            ->where('code', 'wikeyun')
            ->where('serv_type', PRODUCT_POWER_SERV)
            ->whereNull('deleted_at')
            ->find();

        $data = input('');
        Log::write('微客云电费充值回调: ' . json_encode($data, JSON_UNESCAPED_UNICODE));

        if (empty($info)) {
            echo '账号异常';
            exit;
        }

        $model = new \api\power\Wikeyun($info);
        echo $model->notify($data);
    }
}
